package fr.babos.test.components 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import fr.babos.core.masters.MasterSprite;
	import fr.babos.graphic.components.base.BorderContainer;
	import fr.babos.graphic.components.base.ResizableComponent;

	
	/**
	 * @author ZoulouX
	 */
	public class ComponentsTest extends Sprite
	{
		private var _mainContainer:BorderContainer;
		
		public function ComponentsTest ()
		{
			if (stage != null)
				init()
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		protected function init (event:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			stage.frameRate = 60;
			stage.autoOrients = true;
			
			_mainContainer = new BorderContainer(0xFF0000, 1);
			
			_mainContainer.x = 10;
			_mainContainer.y = 10;
			
			addChild(_mainContainer);
			
			var firstLevel:BorderContainer = new BorderContainer(0x00FF00, 1);
			
			firstLevel.size(100, 100);
			
			firstLevel.left = 10;
			firstLevel.right = 10;
			
			firstLevel.verticalCenter = 0;
			
			_mainContainer.addChild(firstLevel);
			
			
			var secondLevel:BorderContainer = new BorderContainer(0x0000FF, 1);
			/*
			secondLevel.top = 10;
			secondLevel.right = 10;
			secondLevel.bottom = 10;
			secondLevel.left = 10;
			*/
			
			secondLevel.size(40, 40);
			//secondLevel.verticalCenter = 0;
			secondLevel.horizontalCenter = 0;
			
			
			secondLevel.top = 10;
			secondLevel.bottom = 10;
			
			_mainContainer.addChild(secondLevel);
			
			stage.addEventListener(Event.RESIZE, stageResizedHandler);
		}
		
		protected function stageResizedHandler (event:Event = null):void
		{
			_mainContainer.size(stage.stageWidth - 20, stage.stageHeight - 20);
		}
	}
}